package com.sxm.yiwei.activitis;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.sxm.yiwei.R;

public class RangingResultActivity extends BaseActivity implements View.OnClickListener{

    private ImageView resultback;
    private TextView textaddress,textdistance;
    private TextView texttype;
    private TextView textlinkman;
    private Button resultsurebt;
    private String id;
    private String inname;
    private String inaddress;
    private String distance;
    private String linknam;
    private String tellphone1;
    private String type;
    private ImageView backmain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ranging_result);
        initResultView();
        Intent intent = getIntent();
        id = intent.getStringExtra("id");
        inname = intent.getStringExtra("inname");
        inaddress = intent.getStringExtra("inaddress");
        distance = intent.getStringExtra("distance");
        tellphone1 = intent.getStringExtra("tellphone1");
        textlinkman.setText(inname+" "+tellphone1);
        textaddress.setText(inaddress);
        Double dd = Double.valueOf(distance);
        textdistance.setText(dd/1000+"");
        texttype.setText("公里");

    }

    private void initResultView() {
        resultback = (ImageView) findViewById(R.id.rangingresult_back);
        textaddress = (TextView) findViewById(R.id.result_textaddress);
        textdistance = (TextView) findViewById(R.id.result_textdistance);
        texttype = (TextView) findViewById(R.id.result_textdistancetype);
        textlinkman = (TextView) findViewById(R.id.result_textlinkman);
        resultsurebt = (Button) findViewById(R.id.rangresult_surebt);
        backmain = (ImageView) findViewById(R.id.rangingresultt_backmain);
        backmain.setOnClickListener(this);
        resultback.setOnClickListener(this);
        resultsurebt.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.rangingresult_back:
                finish();
                break;
            case R.id.rangresult_surebt:

                Intent intent = new Intent(RangingResultActivity.this,RangingResultPriceActivity.class);
                intent.putExtra("id",id);
                intent.putExtra("distance",String.valueOf(distance));
                intent.putExtra("tellphone1",tellphone1);
                intent.putExtra("inname",inname);
                intent.putExtra("inaddress",inaddress);

                startActivity(intent);
                break;
        }
    }
}
